<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./../sablon/2col1cont.xhtml">
            <ui:define name="bread"></ui:define>
            <ui:define name="sol_Men">
                <h:form>
                    <p:menu model="#{leftMenu.model}"/>
                </h:form>
            </ui:define>
            <ui:define name="content"> 
                <h:form id="form">
                    <p:growl id="gr"/>
                    <p:dataTable var="us" value="#{userDto.userList}" paginator="true" rows="20" paginatorPosition="bottom"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                 rowsPerPageTemplate="10,20,30" selection="#{userDto.selectedUser}" selectionMode="single"  >
                        <f:facet name="header">
                            <h:outputText value="Kullanıcı Listesi"/>
                            <p:commandButton value="Yeni Kullanıcı" style="float:right;height:20px;top:-5px"
                                             onclick="addPanel.show()" title="Yeni Kullanıcı" type="button"/>
                        </f:facet>
                        <p:column filterBy="#{us.id}" sortBy="#{us.id}" headerText="ID">
                            <h:outputText value="#{us.id} "/>
                        </p:column>
                        <p:column sortBy="#{us.username}" filterBy="#{us.username}" headerText="Username">
                            <h:outputText value="#{us.username}"/>
                        </p:column>
                        <p:column headerText="Password">
                            <h:outputText value="#{us.password}"/>
                        </p:column>
                        <p:column filterBy="#{us.email}" sortBy="#{us.email}" headerText="Email">
                            <h:outputText value="#{us.email}"/>
                        </p:column>
                    </p:dataTable>
                           
                    <p:dialog widgetVar="addPanel" header="Yeni Kullanıcı " position="center" width="400"  >
                        <h:panelGrid columns="2">
                            <h:outputText value="User            :"/>
                            <p:inputText value="#{userDto.username}"/>
                            <h:outputText value="Şifre           :"/>
                            <p:password promptLabel="Lütfen şifre giriniz" feedback="true" minLength="5" maxlength="12"
                                        weakLabel="Zayıf" goodLabel="Orta seviye" strongLabel="Güçlü" lang="tr" inline="true"
                                        value="#{userDto.password}"/>
                            <h:outputText value="Şifre (Tekrar)  :"/>
                            <p:password feedback="false" minLength="5" value="#{userDto.password2}"/>
                            <h:outputText value="Email           :"/>
                            <p:inputText value="#{userDto.email}"/>
                            <f:verbatim/>

                            <h:panelGroup>
                                <p:commandButton value="İptal" type="reset" oncomplete="addPanel.hide()" update="gr"/>
                                <p:commandButton value="Onayla"  update="gr" oncomplete="addPanel.hide()" action="#{userDto.addUser()}"/>
                            </h:panelGroup>
                        </h:panelGrid>
                    </p:dialog>

                </h:form>
            </ui:define>
            <ui:define name="foot"></ui:define>
        </ui:composition>

    </body>
</html>
